package kernel

import (
	"ginfwk/framework/bootstrap"
	"ginfwk/framework/core/gins/middlewares"
	"ginfwk/framework/provider"
	"github.com/gin-gonic/gin"
)

type HttpKernel interface {
	BootStrappers() []Bootstrapper
	Providers() []Provider
	Middlewares() []gin.HandlerFunc
}

type GHttpKernel struct {
}

type Bootstrapper func()
type Provider func()

func (h *GHttpKernel) BootStrappers() []Bootstrapper {
	return []Bootstrapper{
		bootstrap.InitConfig,
		bootstrap.InitDatabase,
		bootstrap.InitLogger,
		bootstrap.InitComponentCarbon,
	}
}

func (h *GHttpKernel) Providers() []Provider {
	return []Provider{
		provider.RegisterCache,
		provider.RegisterQueue,
		provider.GinDebugPrintRegister,
	}
}

func (h *GHttpKernel) Middlewares() []gin.HandlerFunc {
	return []gin.HandlerFunc{
		middlewares.Tracer(),
		middlewares.Cors(),
		middlewares.GinRecovery(),
		middlewares.Logger(),
	}
}
